<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="student.name">
    </div>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            message:'',
            student:{
                name:'zhangsan',
                age:18
            }
        },
        /*第一种写法
        watch: {
            message:function(newVal,oldVal){
                console.log(newVal+"------->"+oldVal);
            }           
        },
        */
        watch: {
            student:{
                handler:function(newVal,oldVal){
                    console.log(newVal.name+"------->"+oldVal.name);
                },
                deep:true
            }
        },
    });
    /*
    vm.$watch('student',function(newVal,oldVal){
        console.log(newVal.name+"------->"+oldVal.name);
    },{
       deep:true
    });
    */
</script>